import HttpKit from '@/utils/http-kit'

export default {
  /**
   * @description 从后台获取小区列表
   * @returns {communityList}
   */
  getAllCommunities () {
    return HttpKit.get('/communityManage/communities', {pageNumber: 0, pageSize: 500}).then(
      res => res.data
    )
  },
  /**
   * @description 通过小区id获取相对应的小区
   * @param communityId
   * @returns {communicationFrom}
   */
  getSpotsByCommunity (communityId) {
    return HttpKit.get('/communityManage/spots/' + communityId, {pageNumber: 0, pageSize: 500}).then(
      res => res.data
    )
  },
  /**
   * @description 添加小区api
   * @param communityVo 要添加的小区对象
   * @returns {*}
   */
  addCommunityForm (communityVo) {
    return HttpKit.post('/communityManage/community', {
      'address': communityVo.address,
      'districtId': communityVo.districtId,
      'id': 0,
      'latitude': communityVo.latitude,
      'longitude': communityVo.longitude,
      'name': communityVo.name,
      'tradeArea': communityVo.tradeArea,
      'tradeAreaId': communityVo.tradeAreaId,
      'type': communityVo.type
    }).then(
      res => res.data
    )
  },
  /**
   * @description 通过小区id获得小区的信息
   * @param communityId 小区编号
   * @returns {community}
   */
  deleteCommunity (communityId) {
    return HttpKit.delete('/communityManage/community/' + communityId, {}).then(
      res => res.data
    )
  }
}
